﻿using System.Linq;

namespace Ipmce.RemoteVoting.Common.Tools.CardReader.ImageParsing
{
	class FacialRecordHeader : BdbData
	{
		// Indicates face image data
		private static readonly byte[] FormatIdentifier = { 0x46, 0x41, 0x43, 0x00 };
		// Version number
		private static readonly byte[] VersionNumber = { 0x30, 0x31, 0x30, 0x00 };
		// Size in bytes
		private const int Size = 14;

		public int LengthOfRecord
		{
			get { return GetInt(8, 4); }
			set { SetInt(8,4,value); }
		}
		public int NumberOfFacialImages
		{
			get { return GetInt(12, 2); }
			set { SetInt(12, 2, value); }
		}

		public FacialRecordHeader()
			: base(Size) { } 

		public FacialRecordHeader(FacialRecord facialRecord)
			: base(Size)
		{
			NumberOfFacialImages = facialRecord.FacialRecordDataList.Count;
			LengthOfRecord = Size + facialRecord.FacialRecordDataList.Sum(p => p.GetSize());
			SetByteArray(0, FormatIdentifier);
			SetByteArray(4, VersionNumber);
		}
	}
}